<template>
  <div class="limit-info">
    <div class="title">
      <span class="info">涨停数据</span>
      <Calendar :defaultDate="defaultDate" @updateDate="$emit('updateDate', $event)" />
    </div>
    <div class="contents" v-if="limitUpData && limitUpData.length">
      <div class="content" v-for="(items, index) in limitUpData" :key="index">
        <div v-for="item in items" :class="{ line: true, full: item.needFull }" :key="item.name">
          <div class="label">{{ item.name }}</div>
          <div class="value" v-if="item.isGreenRed" v-redGreen="item.value">
            {{ item.value | judgeIsNull }}
          </div>
          <div class="value" v-else>
            {{ item.value | judgeIsNull }}
          </div>
        </div>
      </div>
    </div>
    <atom-empty type="search" v-else title="当前日期该个股未触及涨停" />
  </div>
</template>

<script>
import Calendar from '@/components/common/Calendar.vue';
import { convertNumber } from '@/scripts/tools.js';
export default {
  components: {
    Calendar,
  },
  props: {
    defaultDate: {
      type: Date,
      default: null,
    },
    limitUpData: {
      type: Array,
      default: () => [],
    },
  },
  data() {
    return {};
  },
  filters: {
    convertToBillion(number) {
      return convertNumber(number, 'hundredMillion');
    },
    convertToTenThousand(number) {
      return convertNumber(number, 'tenThousand');
    },
  },
};
</script>
<style lang="less" scoped>
.limit-info {
  box-sizing: border-box;
  padding: 0 32px 0;
  background: var(--bg-color-2);
  margin-bottom: 16px;
  .title {
    width: 100%;
    height: 108px;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .info {
      font-family: PingFangSC-Medium;
      font-size: 36px;
      color: var(--text-1);
      letter-spacing: 0;
      line-height: 44px;
      font-weight: 500;
    }
  }
  .contents {
    box-sizing: border-box;
    .content {
      width: 100%;
      display: flex;
      flex-wrap: wrap;
      padding-bottom: 8px;
      &:first-child {
        margin-bottom: 32px;
        border-bottom: 1px solid var(--text-8);
      }

      .line {
        width: 50%;
        height: 36px;
        display: flex;
        // justify-content: space-between;
        align-items: center;
        margin-bottom: 24px;
        &.full {
          width: 100%;
          .value {
            width: 546px;
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
          }
        }
        .label {
          font-family: PingFangSC-Regular;
          font-size: 28px;
          color: var(--text-5);
          letter-spacing: 0;
          text-align: justify;
          line-height: 36px;
          font-weight: 400;
          white-space: nowrap;
        }
        .value {
          font-family: PingFangSC-Regular;
          font-size: 28px;
          color: var(--text-1);
          letter-spacing: 0;
          text-align: justify;
          line-height: 36px;
          font-weight: 400;
          margin-left: 28px;
          white-space: nowrap;
        }
      }
    }
  }
}
</style>
